import 'package:flutter/material.dart';
import 'package:interview/theme/app_colors.dart';

class OptTabbar extends StatelessWidget {
  final AppColors theme;
  final TabController tabController;
  final int currentIndex;
  final List<Map<String , dynamic>> tabbarList;
  final void Function(int) onTabTapped;

  const OptTabbar({
    super.key, 
    required this.theme, 
    required this.tabController, 
    required this.currentIndex, 
    required this.tabbarList, 
    required this.onTabTapped
  });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(left: 16),
      child: Align(
        alignment: Alignment.centerLeft,
        child: TabBar(
          isScrollable:true,
          tabAlignment: TabAlignment.start,
          controller: tabController,
          indicatorColor: theme.contrastPure, // 选中状态下划线
          unselectedLabelStyle: TextStyle(
            fontWeight: FontWeight.normal,
            color: theme.contrastMix1,
          ),
          labelStyle: TextStyle(
            fontWeight: FontWeight.bold,
            color: theme.contrastPure,
          ),
          dividerHeight: 0,
          onTap: onTabTapped,
          tabs: tabbarList.map((i){
            return Tab(
              child: Text(i["optText"] , style: TextStyle(fontSize: 13))
            );
          }).toList()
        ),
      )
    );
  }
}
